package com.wb.spring.boot.autoconfigure.load;

import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.math.NumberUtils;

import java.util.List;

/**
 * 哈希
 */
public class RandomLoad implements Load {

    private Integer index = NumberUtils.INTEGER_ZERO;

    @Override
    public String load(List<String> servers) {
        index = RandomUtils.nextInt(0, servers.size());
        return servers.get(index);
    }
}
